import { BasicFetchResult, SaaSBasicPageParams } from '../../model/baseModel';

// 请求参数：根据应用 + 所属企业，搜索任务列表
export type UpgradeTaskQueryParams = {
  appId: string;
  tenantCode: string;
};

// 分页请求参数：根据应用 + 所属企业，搜索任务列表
export type UpgradeTaskQueryPageParams = UpgradeTaskQueryParams & SaaSBasicPageParams;

// 升级任务列表条目信息
export interface UpgradeTaskListItem {
  id: string;
  name: string;
  type: string;
  description: string;
  appId: string;
  appName: string;
  tenantCode: string;
  tenantName: string;
  packageId: string;
  instanceType: string;
  componentId: string;
  componentName: string;
  previousImageId: string;
  previousImageName: string;
  previousVersion: string;
  currentImageId: string;
  currentImageName: string;
  currentVersion: string;
  status: string;
  duration: string;
}

// 响应参数：升级任务列表封装
export type UpgradeTaskListResultModel = BasicFetchResult<UpgradeTaskListItem>;

// 灰度升级参数
export type GrayParamItem = {
  headersField: string;
  type: string;
  pattern: string;
  weight: number;
  precedence: number;
};

// 升级任务创建
export type UpgradeTaskCreateItem = {
  id: string;
  app: string;
  component: string;
  instance: string;
  tenant: string;
  name: string;
  type: string;
  appId: string;
  tenantCode: string;
  packageId: string;
  componentId: string;
  description: string;
  cceNamespace: string;
  currentImage: string;
  currentImageId: string;
  currentVersion: string;
  previousCceDeployment: string;
  previousImageId: string;
  previousVersion: string;
  maxUnavailable: number;
  maxSurge: number;
  weight: number;
  grayParamDtoList: GrayParamItem[];
};

// 根据任务ID查看升级任务详情
export type UpgradeTaskViewParams = {
  taskId: string;
};

// 升级任务详情
export type UpgradeTaskViewItem = {
  id: string;
  name: string;
  type: string;
  app: string;
  tenant: string;
  instance: string;
  component: string;
  description: string;
  cceNamespace: string;
  currentImage: string;
  currentVersion: string;
  previousCceDeployment: string;
  previousImage: string;
  previousVersion: string;
  maxUnavailable: number;
  maxSurge: number;
  weight: number;
  grayParamDtoList: GrayParamItem[];
  status: string;
  duration: string;
  errMsg: string;
};

// 请求参数：编辑升级任务
export type UpgradeTaskEditItem = {
  id: string;
  name: string;
  description: string;
  type: string;
  maxUnavailable?: number;
  maxSurge?: number;
  weight?: number;
  grayParamDtoList?: GrayParamItem[];
};
